package com.nexus.plugin.amqp.handle;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * 消息路由失败时的回调
 *
 * @Date 2025/9/24 03:19
 * @Author luzhengning
 **/
@Slf4j
public class EnhancedReturnsCallback implements RabbitTemplate.ReturnsCallback {
    @Override
    public void returnedMessage(ReturnedMessage returned) {
        log.error("消息路由失败 - 回复码: {}, 原因: {}, 交换机: {}, 路由键: {}, 消息: {}",
                returned.getReplyCode(), returned.getReplyText(),
                returned.getExchange(), returned.getRoutingKey(),
                new String(returned.getMessage().getBody()));
    }
}